.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document.  The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
.\" Copyright (c) 2000, Sun Microsystems, Inc.  All Rights Reserved
.\"
.TH WHO 1 "August 13, 2023"
.SH NAME
who \- who is on the system
.SH SYNOPSIS
.nf
\fB/usr/bin/who\fR [\fB-abdHlmpqrstTu\fR] [\fIfile\fR]
.fi

.LP
.nf
\fB/usr/bin/who\fR \fB-q\fR [\fB-n\fR \fIx\fR] [\fIfile\fR]
.fi

.LP
.nf
\fB/usr/bin/who\fR am i
.fi

.LP
.nf
\fB/usr/bin/who\fR am I
.fi

.LP
.nf
\fB/usr/xpg4/bin/who\fR [\fB-abdHlmpqrtTu\fR] [\fIfile\fR]
.fi

.LP
.nf
\fB/usr/xpg4/bin/who\fR \fB-q\fR [\fB-n\fR \fIx\fR] [\fIfile\fR]
.fi

.LP
.nf
\fB/usr/xpg4/bin/who\fR \fB-s\fR [\fB-bdHlmpqrtu\fR] [\fIfile\fR]
.fi

.LP
.nf
\fB/usr/xpg4/bin/who\fR am i
.fi

.LP
.nf
\fB/usr/xpg4/bin/who\fR am I
.fi

.SH DESCRIPTION
The \fBwho\fR utility can list the user's name, terminal line, login time,
elapsed time since activity occurred on the line, and the process-ID of the
command interpreter (shell) for each current UNIX system user. It examines the
\fB/var/adm/utmpx\fR file to obtain its information. If \fIfile\fR is given,
that file (which must be in \fButmpx\fR(5) format) is examined. Usually,
\fIfile\fR will be \fB/var/adm/wtmpx\fR, which contains a history of all the
logins since the file was last created.
.sp
.LP
The general format for output is:
.sp
.in +2
.nf
\fIname\fR [\fIstate\fR] \fIline time\fR [\fIidle\fR] [\fIpid\fR] [\fIcomment\fR] [\fIexit\fR]
.fi
.in -2
.sp

.sp
.LP
where:
.sp
.ne 2
.na
\fB\fIname\fR \fR
.ad
.RS 12n
User's login name
.RE

.sp
.ne 2
.na
\fB\fIstate\fR \fR
.ad
.RS 12n
Capability of writing to the terminal
.RE

.sp
.ne 2
.na
\fB\fIline\fR \fR
.ad
.RS 12n
Name of the line found in \fB/dev\fR
.RE

.sp
.ne 2
.na
\fB\fItime\fR \fR
.ad
.RS 12n
Time since user's login
.RE

.sp
.ne 2
.na
\fB\fIidle\fR \fR
.ad
.RS 12n
Time elapsed since the user's last activity
.RE

.sp
.ne 2
.na
\fB\fIpid\fR \fR
.ad
.RS 12n
User's process id
.RE

.sp
.ne 2
.na
\fB\fIcomment\fR \fR
.ad
.RS 12n
Comment line in \fBinittab\fR(5)
.RE

.sp
.ne 2
.na
\fB\fIexit\fR \fR
.ad
.RS 12n
Exit status for dead processes
.RE

.SH OPTIONS
The following options are supported:
.sp
.ne 2
.na
\fB\fB-a\fR \fR
.ad
.RS 9n
Processes \fB/var/adm/utmpx\fR or the named \fIfile\fR with \fB-b\fR, \fB-d\fR,
\fB-l\fR, \fB-p\fR, \fB-r\fR, \fB-t\fR, \fB-T\fR, and \fB-u\fR options turned
on.
.RE

.sp
.ne 2
.na
\fB\fB-b\fR \fR
.ad
.RS 9n
Indicates the time and date of the last reboot.
.RE

.sp
.ne 2
.na
\fB\fB-d\fR \fR
.ad
.RS 9n
Displays all processes that have expired and not been respawned by \fBinit\fR.
The \fBexit\fR field appears for dead processes and contains the termination
and exit values of the dead process. This
can be useful in determining why a process terminated.
.RE

.sp
.ne 2
.na
\fB\fB-H\fR \fR
.ad
.RS 9n
Outputs column headings above the regular output.
.RE

.sp
.ne 2
.na
\fB\fB-l\fR \fR
.ad
.RS 9n
Lists only those lines on which the system is waiting for someone to login. The
\fIname\fR field is \fBLOGIN\fR in such cases. Other fields are the same as for
user entries except that the \fIstate\fR field does not exist.
.RE

.sp
.ne 2
.na
\fB\fB-m\fR \fR
.ad
.RS 9n
Outputs only information about the current terminal.
.RE

.sp
.ne 2
.na
\fB\fB-n\fR \fIx\fR \fR
.ad
.RS 9n
Takes a numeric argument, \fIx\fR, which specifies the number of users to
display per line. \fIx\fR must be at least \fB1\fR. The \fB-n\fR option can
only be used with \fB-q\fR.
.RE

.sp
.ne 2
.na
\fB\fB-p\fR \fR
.ad
.RS 9n
Lists any other process that is currently active and has been previously
spawned by \fBinit\fR. The \fIname\fR field is the name of the program executed
by \fBinit\fR as found in \fB/etc/inittab\fR. The \fIstate\fR, \fIline\fR, and
\fIidle\fR fields have no meaning. The \fIcomment\fR field shows the \fBid\fR
field of the line from \fB/etc/inittab\fR that spawned this process. See
\fBinittab\fR(5).
.RE

.sp
.ne 2
.na
\fB\fB-q\fR \fR
.ad
.RS 9n
(Quick \fBwho\fR) Displays only the names and the number of users currently
logged on. When this option is used, all other options are ignored.
.RE

.sp
.ne 2
.na
\fB\fB-r\fR \fR
.ad
.RS 9n
Indicates the current \fIrun-level\fR of the \fBinit\fR process.
.RE

.sp
.ne 2
.na
\fB\fB-s\fR \fR
.ad
.RS 9n
(Default) Lists only the \fIname\fR, \fIline\fR, and \fItime\fR fields.
.RE

.SS "/usr/bin/who"
.ne 2
.na
\fB\fB-T\fR \fR
.ad
.RS 7n
Same as the \fB-s\fR option, except that the \fIstate\fR \fIidle\fR, \fIpid\fR,
and \fIcomment\fR, fields are also written. \fIstate\fR is one of the following
characters:
.sp
.ne 2
.na
\fB\fB+\fR \fR
.ad
.RS 9n
The terminal allows write access to other users.
.RE

.sp
.ne 2
.na
\fB\fB\(mi\fR \fR
.ad
.RS 9n
The terminal denies write access to other users.
.RE

.sp
.ne 2
.na
\fB\fB?\fR \fR
.ad
.RS 9n
The terminal write-access state cannot be determined.
.RE

.RE

.SS "/usr/xpg4/bin/who"
.ne 2
.na
\fB\fB-T\fR \fR
.ad
.RS 7n
Same as the \fB-s\fR option, except that the \fIstate\fR field is also written.
\fIstate\fR is one of the characters listed under the \fB/usr/bin/who\fR
version of this option. If the \fB-u\fR option is used with \fB-T\fR, the idle
time is added to the end of the previous format.
.RE

.sp
.ne 2
.na
\fB\fB-t\fR \fR
.ad
.RS 7n
Indicates the last change to the system clock (using the \fBdate\fR utility) by
\fBroot\fR. See \fBsu\fR(8) and \fBdate\fR(1).
.RE

.sp
.ne 2
.na
\fB\fB-u\fR \fR
.ad
.RS 7n
Lists only those users who are currently logged in. The \fIname\fR is the
user's login name. The \fIline\fR is the name of the line as found in the
directory \fB/dev\fR. The \fItime\fR is the time that the user logged in. The
\fIidle\fR column contains the number of hours and minutes since activity last
occurred on that particular line. A dot (\fB\&.\fR) indicates that the terminal
has seen activity in the last minute and is therefore ``current.'' If more than
twenty-four hours have elapsed or the line has not been used since boot time,
the entry is marked \fBold\fR. This field is useful when trying to determine
whether a person is working at the terminal or not. The \fIpid\fR is the
process-ID of the user's shell. The \fIcomment\fR is the comment field
associated with this line as found in \fB/etc/inittab\fR (see
\fBinittab\fR(5)). This can contain information about where the terminal is
located, the telephone number of the dataset, type of terminal if hard-wired,
and so forth.
.RE

.SH OPERANDS
The following operands are supported:
.sp
.ne 2
.na
\fB\fBam\fR \fBi\fR \fR
.ad
.br
.na
\fB\fBam\fR \fBI\fR \fR
.ad
.RS 9n
In the "C" locale, limits the output to describing the invoking user,
equivalent to the \fB-m\fR option. The \fBam\fR and \fBi\fR or \fBI\fR must be
separate arguments.
.RE

.sp
.ne 2
.na
\fB\fIfile\fR \fR
.ad
.RS 9n
Specifies a path name of a file to substitute for the database of logged-on
users that \fBwho\fR uses by default.
.RE

.SH ENVIRONMENT VARIABLES
See \fBenviron\fR(7) for descriptions of the following environment variables
that affect the execution of \fBwho\fR: \fBLANG\fR, \fBLC_ALL\fR,
\fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBLC_TIME\fR, and \fBNLSPATH\fR.
.SH EXIT STATUS
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR \fR
.ad
.RS 7n
Successful completion.
.RE

.sp
.ne 2
.na
\fB\fB>0\fR \fR
.ad
.RS 7n
An error occurred.
.RE

.SH FILES
.ne 2
.na
\fB\fB/etc/inittab\fR \fR
.ad
.RS 19n
Script for \fBinit\fR
.RE

.sp
.ne 2
.na
\fB\fB/var/adm/utmpx\fR \fR
.ad
.RS 19n
Current user and accounting information
.RE

.sp
.ne 2
.na
\fB\fB/var/adm/wtmpx\fR \fR
.ad
.RS 19n
Historic user and accounting information
.RE

.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.SS "/usr/xpg4/bin/who"
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Standard
.TE

.SH SEE ALSO
.BR date (1),
.BR login (1),
.BR mesg (1),
.BR inittab (5),
.BR utmpx (5),
.BR attributes (7),
.BR environ (7),
.BR standards (7),
.BR init (8),
.BR su (8)
.SH NOTES
\fBSuperuser:\fR After a shutdown to the single-user state, \fBwho\fR returns a
prompt. Since \fB/var/adm/utmpx\fR is updated at login time and there is no
login in single-user state, \fBwho\fR cannot report accurately on this state.
The command, \fBwho\fR \fBam i\fR, however, returns the correct information.
